package com.ycfmedical.bed.local.dao;

import android.content.Context;

import com.ycfmedical.bed.greendao.gen.DaoSession;
import com.ycfmedical.bed.local.entity.HisSystemInfo;
import com.ycfmedical.bed.utils.AssetsHelper;
import com.ycfmedical.bed.utils.GsonHelper;

import java.util.List;

/**
 * Created by Administrator on 2017/3/16 0016.
 */

public class HisSystemInfoDao
{

    private HisSystemInfoDao()
    {

    }

    // His系统所有栏目
    private static List<HisSystemInfo> hisSystemInfoList;

    /**
     * 更新用户HIS系统信息本地数据
     * 
     * @param context
     * @param daoSession
     */
    public static void updateLocalData(Context context, DaoSession daoSession)
    {
        hisSystemInfoList = GsonHelper.convertEntities(AssetsHelper.readData(context, "HisSystemInfoTab"),
            HisSystemInfo.class);
        for (HisSystemInfo hisSystemInfo : hisSystemInfoList) {
            String s = hisSystemInfo.toString();
            String ss = hisSystemInfo.toString();
        }
        com.ycfmedical.bed.greendao.gen.HisSystemInfoDao beanDao = daoSession.getHisSystemInfoDao();
        if (beanDao.count() == 0)
        {
            beanDao.insertInTx(hisSystemInfoList);
        }
    }

    /**
     * 获取当前用户HIS系统的所有信息
     * 
     * @return
     */
    public static List<HisSystemInfo> getAllHisInfoList()
    {
        return hisSystemInfoList;
    }
}
